﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/SysUser/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    $("#UserPassword").val("******").attr('disabled', 'disabled');
                }
            });
        }
    });
    function initControl() {

        $("#Gender").bindSelect();
        $("#IsAdministrator").bindSelect();
        $("#EnabledMark").bindSelect();
        $("#OrganizeId").bindSelect({
            url: "/SystemManage/SysOrganize/GetCompanyTreeSelectJson"
        });

        //alert($("#OrganizeId").val()); //获取选中值
        //$("#OrganizeId").val("cff39c04-b4fa-407b-8baa-1ca140a833dc").trigger("change"); //默认选中
        $('#OrganizeId').change(function () {
            //  alert($(this).val());
            $("#DepartmentId").empty();
            $("#DepartmentId").append("<option value=''>请选择</option>");
            $("#DepartmentId").bindSelect({
                url: "/SystemManage/SysOrganize/GetDepartmentTreeSelectJson?parentId=" + $(this).val()
            });

            $("#DepartmentId").prop("disabled", false);
        });

        $('#DepartmentId').change(function () {
            $("#PositionId").empty();
            $("#PositionId").append("<option value=''>请选择</option>");
            $("#PositionId").bindSelect({
                url: "/SystemManage/SysOrganize/GetWorkTreeSelectJson?parentId=" + $(this).val()
            });
            $("#PositionId").prop("disabled", false);
        });

        //部门禁用
        $("#DepartmentId").prop("disabled", true);
        $("#PositionId").prop("disabled", true);

        $("#RoleId").bindSelect({
            url: "/SystemManage/SysRole/GetGridJson",
            id: "Id",
            text: "FullName"
        });

    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        } var submitUrl = "Insert";
        if (!!keyValue) {
            submitUrl = "Update";
        }
        $.submitForm({
            url: "/SystemManage/SysUser/" + submitUrl + "?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
        return false;
    }
</script>
<form id="form1">
    <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#">基本信息</a></li>
            @*<li ><a href="#">扩展信息</a></li>*@
        </ul>
        <div style="padding-top: 20px; margin-right: 30px;">
            <table class="form">
                <tr>
                    <th class="formTitle">账户</th>
                    <td class="formValue Value">
                        <input id="Account" name="Account" type="text" class="form-control required" placeholder="请输入账户" />
                    </td>
                    <th class="formTitle">密码</th>
                    <td class="formValue Value">
                        <input id="UserPassword" name="UserPassword" type="password" class="form-control required" placeholder="请输入密码" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">公司</th>
                    <td class="formValue Value">
                        <select id="OrganizeId" name="Organizeid" class="form-control required">
                            <option value="">请选择</option>
                        </select>
                    </td>
                    <th class="formTitle">部门</th>
                    <td class="formValue Value">
                        <select id="DepartmentId" name="Departmentid" class="form-control required">
                            <option value="">请选择</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">角色</th>
                    <td class="formValue Value">
                        <select id="RoleId" name="RoleId" class="form-control required">
                            <option value="">请选择</option>
                        </select>
                    </td>
                    <th class="formTitle">岗位</th>
                    <td class="formValue Value">
                        <select id="PositionId" name="PositionId" class="form-control required">
                            <option value="">请选择</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">姓名</th>
                    <td class="formValue Value">
                        <input id="RealName" name="RealName" type="text" class="form-control required" placeholder="请输入姓名" />
                    </td>
                    <th class="formTitle">性别</th>
                    <td class="formValue Value">
                        <select id="Gender" name="Gender" class="form-control required">
                            <option value="true">男</option>
                            <option value="false">女</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">手机</th>
                    <td class="formValue Value">
                        <input id="MobilePhone" name="MobilePhone" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">生日</th>
                    <td class="formValue Value">
                        <input id="Birthday" name="Birthday" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">微信</th>
                    <td class="formValue Value">
                        <input id="WeChat" name="WeChat" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">邮箱</th>
                    <td class="formValue Value">
                        <input id="Email" name="Email" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">类型</th>
                    <td class="formValue Value">
                        <select id="IsAdministrator" name="IsAdministrator" class="form-control">
                            <option value="false">普通用户</option>
                            <option value="true">系统管理员</option>
                        </select>
                    </td>
                    <th class="formTitle">允许登录</th>
                    <td class="formValue Value">
                        <select id="EnabledMark" name="EnabledMark" class="form-control">
                            <option value="true">是</option>
                            <option value="false">否</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formValue Value" valign="top" style="padding-top: 5px;">
                        备注
                    </th>
                    <td class="formValue Value" colspan="3">
                        <textarea id="Description" name="Description" class="form-control" style="height: 60px;"></textarea>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>
